package oplog

import (
	"data/config"
	"public/mysqldb"
	"time"
)

/*
	添加日志数据
*/
func OnAddOpLog(operator, receive, topic, bundle, pid, ip_addr string, tm0 time.Time, num0 int, Attach0 string) bool {
	var info Op_log_tbl
	info.Operator = operator
	info.Receive = receive
	info.Create_time = time.Now()
	info.Topic = topic
	info.Bundle = bundle
	info.Pid = pid
	info.Ip_addr = ip_addr
	info.Tm0 = tm0
	info.Num0 = num0
	info.Attach0 = Attach0

	return OpLogBaseAdd(info)
}

/*
	添加日志数据
*/
func OpLogBaseAdd(info Op_log_tbl) bool {
	info.Create_time = time.Now() //默认时间

	var db mysqldb.MySqlDB
	defer db.OnDestoryDB()
	orm := db.OnGetDBOrm(config.GetDbUrl())
	orm.Create(&info)
	return true
}
